package com.weishu.housing.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.weishu.common.core.web.domain.AjaxResult;
import com.weishu.core.entity.TbFensanHouse;
import com.weishu.common.security.annotation.PreAuthorize;
import com.weishu.core.entity.*;
import com.weishu.core.service.ISysRegionService;
import com.weishu.core.service.ITbRoomInfoService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/fangtai")
public class FangtaiRoomController {


    @Autowired
    private ITbRoomInfoService iTbRoomInfoService;
    @Autowired
    private ISysRegionService iSysRegionService;


    /**
     * 省
     */

    @GetMapping("getsheng")
    public List<SysRegion> getsheng(){
        List<SysRegion> getsheng = iSysRegionService.getsheng();
        for (SysRegion sysRegion : getsheng) {
            System.out.println(sysRegion);
        }
        return getsheng;
    }
    /**
     * 市
     * @param tbPremisesInfo  楼盘信息
     * @return
     */
    @GetMapping("getshi")
    public List<SysRegion> getshi(TbPremisesInfo tbPremisesInfo){

        return iSysRegionService.getshi(tbPremisesInfo.getProvince());
    }
    /**
     * 县
     * @param tbPremisesInfo 楼盘信息
     * @return
     */
    @GetMapping("getxian")
    public List<SysRegion> getxian(TbPremisesInfo tbPremisesInfo){
        return iSysRegionService.getshi(tbPremisesInfo.getCity());
    }

    @RequestMapping("list")
    public AjaxResult fangtailist(TbFensanHouse tbFensanHouse, Integer pageNo, Integer pageSize){
        List<TbFensanHouse> tbFensanHouses = iTbRoomInfoService.queryFensanlist(tbFensanHouse);
        PageHelper.startPage(pageNo, pageSize);
        PageInfo<TbFensanHouse> pageInfo=new PageInfo<>(tbFensanHouses);
        return AjaxResult.success(pageInfo);
    }
    @RequestMapping("listjizhong")
    public AjaxResult fangtailistjizhong(TbFensanHouse tbFensanHouse, Integer pageNo, Integer pageSize){
        List<TbFensanHouse> tbFensanHouses = iTbRoomInfoService.queryFensanlistjizhong(tbFensanHouse);
        PageHelper.startPage(pageNo, pageSize);
        PageInfo<TbFensanHouse> pageInfo=new PageInfo<>(tbFensanHouses);
        return AjaxResult.success(pageInfo);
    }
    @RequestMapping("listfensan")
    public AjaxResult fangtailistfensan(TbFensanHouse tbFensanHouse, Integer pageNo, Integer pageSize){
        List<TbFensanHouse> tbFensanHouses = iTbRoomInfoService.queryFensanlistfensan(tbFensanHouse);
        PageHelper.startPage(pageNo, pageSize);
        PageInfo<TbFensanHouse> pageInfo=new PageInfo<>(tbFensanHouses);
        return AjaxResult.success(pageInfo);
    }


}
